using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace nDeveloper.VSS
{
    public partial class frmShowHistory : Form
    {
        private VSSHitoryItemCollection _vssHitoryItemCollection;

        public frmShowHistory(VSSHitoryItemCollection vssHitoryItemCollection)
		{
			_vssHitoryItemCollection = vssHitoryItemCollection;

			InitializeComponent();
		}

        private void frmShowHistory_Load(object sender, EventArgs e)
        {
            foreach (VSSHitoryItem item in _vssHitoryItemCollection)
            {
                ListViewItem lvi = HistoryList.Items.Add(item.Text);
                lvi.SubItems.Add(item.Username);
                lvi.SubItems.Add(item.Date);
                lvi.SubItems.Add(item.Action);
            }
        }

        private void btnDiff_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void HistoryList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (HistoryList.SelectedItems.Count > 2)
                foreach (ListViewItem lvi in HistoryList.Items)
                {
                    lvi.Selected = false;
                }

            int n = HistoryList.SelectedItems.Count;
            switch (n)
            {
                case 1:
                    btnDiff.Enabled = false;
                    btnDifflocal.Enabled = true;
                    break;
                case 2:
                    btnDiff.Enabled = true;
                    btnDifflocal.Enabled = false;
                    break;
                default:
                    btnDiff.Enabled = false;
                    btnDifflocal.Enabled = false;
                    break;
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void btnDifflocal_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }
    }
}